import calendar
from datetime import datetime


def third_friday(year):
    third_fridays = []

    for month in range(1, 13):
        # 创建一个月的日历信息
        month_calendar = calendar.monthcalendar(year, month)

        # 查找第三个周五
        friday_count = 0
        for week in month_calendar:
            if week[calendar.FRIDAY] != 0:
                friday_count += 1
                if friday_count == 3:
                    third_fridays.append(week[calendar.FRIDAY])
                    break
    third_fridays2 = []
    for month, day in enumerate(third_fridays, start=1):
        third_fridays2.append(datetime(year, month, day, tzinfo = None))
    return third_fridays2


if __name__ == '__main__':
    # Example usage:
    year = 2024
    third_fridays = third_friday(year)
    print(third_fridays)
